using UnityEngine;
using System.Collections;

public class Basket : MonoBehaviour {

	public float targetX;
	float speed;
	public bool isMouseOver = false;
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
	
	}
	
	void FixedUpdate(){
		float distance = Input.GetAxis("Horizontal");
		if(isMouseOver && distance==0f){
			speed = 2f;
			distance = UICamera.lastHit.point.x - transform.position.x;
			if(Mathf.Abs(distance)<0.1f) distance = 0f;
		}
		else{
			speed = 1.5f;
		}
		
		if(distance>0f && transform.localPosition.x<280f){
			transform.position = new Vector3(transform.position.x+speed*Time.deltaTime,transform.position.y,
				transform.position.z);
		}
		else if(distance<0f && transform.localPosition.x>-280f){
			transform.position = new Vector3(transform.position.x-speed*Time.deltaTime,transform.position.y,
				transform.position.z);
		}
	}
}
